<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 1. 先准备一个容器 -->
    <div id="app">
      <ul>
        <li v-for="(item,index) in booksList">{{item.name}} - {{index}}</li>
      </ul>

      <ul>
        <li v-for="item in booksList">{{item.name}}</li>
      </ul>
    </div>
    <!-- 2. 引框架 -->
    <script src="./vue.js"></script>
    <script>
      // 3.初始化vue实例对象
      const vm = new Vue({
        el: "#app",
        data: {
          booksList: [
            { id: 1, name: "《红楼梦》", author: "曹雪芹" },
            { id: 2, name: "《西游记》", author: "吴承恩" },
            { id: 3, name: "《水浒传》", author: "施耐庵" },
            { id: 4, name: "《三国演义》", author: "罗贯中" },
          ],
        },
      });

      //   v-for是和forEach
      //   1. index可以不写
      // 2. item,index名字是随便起的，只不过这二个名字是行业规范
      //   const list = [
      //     { id: 1, name: "《红楼梦》", author: "曹雪芹" },
      //     { id: 2, name: "《西游记》", author: "吴承恩" },
      //     { id: 3, name: "《水浒传》", author: "施耐庵" },
      //     { id: 4, name: "《三国演义》", author: "罗贯中" },
      //   ];
      //   list.forEach(function (item, index) {
      //     console.log(item);
      //     console.log(index);
      //   });
    </script>
  </body>
</html>
